package com.example.leaderapplication.Base;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

public abstract class BaseFragment extends Fragment {
    protected View view;
    protected Activity mActivity;

    @Override
    public View onCreateView( LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
        view = setView(inflater);
        mActivity = getActivity();
        initView();
        initData();

        return view;
    }

    public abstract View setView( LayoutInflater inflater);
    //初始化控件
    public abstract void initView();
    //初始化数据
    public abstract void initData();

    /**
     * 跳转到下一页面
     * @param clazz
     */
    public void showNext(Class clazz, Bundle bundle){
        Intent intent = new Intent(mActivity,clazz);
        if (bundle != null){
            intent.putExtra("args",bundle);
        }
        startActivity(intent);
    }



}
